﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Last03.Aqiantai
{
    /// <summary>
    /// ydxiugai.xaml 的交互逻辑
    /// </summary>
    public partial class ydxiugai : Page
    {
        public ydxiugai()
        {
            InitializeComponent();
        }
        HotelEntities context = new HotelEntities();

        private void Button_Click(object sender, RoutedEventArgs e)
        {//查看已预定信息
            ShowYuding();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {//更改预定信息
            string ggsql = "update Yuding set 入住时间={0} where 身份证号={1}";
            int j = context.Database.ExecuteSqlCommand(ggsql, txtrzsj.Text, txtsfzh.Text);
            if (j < 0)
            {
                MessageBox.Show("请重新输入相关信息！");
            }
            ShowYuding();
        }

        private void ShowYuding()
        {
            var q = context.Database.SqlQuery<Yuding>("select * from Yuding");
            this.dataGrid.ItemsSource = q.ToList();
        }

        private void txtsfzh_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            this.txtsfzh.Text = "";
        }

        private void txtrzsj_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            this.txtrzsj.Text = "";
        }
    }
}
